
import random
from PIL import Image,ImageDraw,ImageFont
import hashlib
import datetime


mp = hashlib.md5()
mp.update(str(datetime.datetime.now())+str(random.random()))
mp_src = mp.hexdigest()
rand_str = mp_src[0:6]
font = ImageFont.truetype("KARISMAS.ttf", 25)
width = 75
height = 30
im = Image.new('RGB',(width,height),'#%s'%mp_src[-7:-1])
draw = ImageDraw.Draw(im)
draw.line((random.randint(0,width),random.randint(0,height),random.randint(0,width),random.randint(0,height)))
draw.line((random.randint(0,width),random.randint(0,height),random.randint(0,width),random.randint(0,height)))
draw.line((random.randint(0,width),random.randint(0,height),random.randint(0,width),random.randint(0,height)))
draw.line((random.randint(0,width),random.randint(0,height),random.randint(0,width),random.randint(0,height)))
draw.line((random.randint(0,width),random.randint(0,height),random.randint(0,width),random.randint(0,height)))
draw.text((5,2), rand_str, font=font)
del draw

im.save('icode.jpg')
auth_code = rand_str
print auth_code
